﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

namespace VirtualTournaments.Frontend.MenuControls.GamblingManagerMenu.InnerControls
{
    public partial class TeamSelection : System.Web.UI.UserControl
    {
        public EventHandler GoToTeamInfoButton;
        
        public ListItemCollection TeamsInTournament 
        {
            get { return TeamsListBox.Items; }
            private set{}
        }

        protected void FirstPlaceToButton_OnClick(object sender, EventArgs e)
        {
            if (!FirstPlaceTeam.Text.Equals("Team: "))
            {
                TeamsListBox.Items.Add(FirstPlaceTeam.Text);
            }
            FirstPlaceTeam.Text = TeamsListBox.SelectedValue;
            TeamsListBox.Items.RemoveAt(TeamsListBox.SelectedIndex);
            
        }
        protected void FirstPlaceFromButton_OnClick(object sender, EventArgs e) 
        {
            if (!FirstPlaceTeam.Text.Equals("Team: ")) 
            {
                TeamsListBox.Items.Add(FirstPlaceTeam.Text);
                FirstPlaceTeam.Text = "Team: ";
            }
        }

        protected void SecondPlaceToButton_OnClick(object sender, EventArgs e)
        {
            if (!SecondPlaceTeam.Text.Equals("Team: "))
            {
                TeamsListBox.Items.Add(SecondPlaceTeam.Text);
            }
            SecondPlaceTeam.Text = TeamsListBox.SelectedValue;
            TeamsListBox.Items.RemoveAt(TeamsListBox.SelectedIndex);
            
        }
        protected void SecondPlaceFromButton_OnClick(object sender, EventArgs e)
        {
            if (!SecondPlaceTeam.Text.Equals("Team: "))
            {
                TeamsListBox.Items.Add(SecondPlaceTeam.Text);
                SecondPlaceTeam.Text = "Team: ";
            }
        }

        protected void ThirdPlaceToButton_OnClick(object sender, EventArgs e)
        {
            if (!ThirdPlaceTeam.Text.Equals("Team: "))
            {
                TeamsListBox.Items.Add(ThirdPlaceTeam.Text);
            }
            ThirdPlaceTeam.Text = TeamsListBox.SelectedValue;
            TeamsListBox.Items.RemoveAt(TeamsListBox.SelectedIndex);
        }
        protected void ThirdPlaceFromButton_OnClick(object sender, EventArgs e)
        {
            if (!ThirdPlaceTeam.Text.Equals("Team: "))
            {
                TeamsListBox.Items.Add(ThirdPlaceTeam.Text);
                ThirdPlaceTeam.Text = "Team: ";
            }
        }

        protected void TeamInfoButton_OnClick(object sender, EventArgs e) 
        {
            GoToTeamInfoButton(this, new VirtualTournamentsFrontendEvent());
        }
    }
}